<template>
	<div class="port-page">
		<!-- 顶部按钮 -->
		<div class="but1">
			<router-link to="/home">
				<el-button type="warning" size="small" style='margin-right: 5px;' icon="el-icon-menu">首页</el-button>
			</router-link>
			<router-link :to="{path:'/home',query: {id:vbjid,frompage:'bk'}}">
				<el-button type="warning" size="small" style='margin-right: 0px;' icon="el-icon-caret-left">返回</el-button>
			</router-link>
			<router-link to="/educa/lsbkap">
				<el-button type="success" size="small" style='margin-right: 0px;' icon="el-icon-date">查看补课安排</el-button>
			</router-link>
			<div class="but2">
				<el-select v-model="vbjid" clearable class="code-search" @change="search" v-if="kqlb" placeholder="请选择班级">
					<el-option :label="v.mc" :value="v.id+''" v-for="v in bjmclist"></el-option>
				</el-select>
				<el-select v-model="vbjid" clearable class="code-search" @change="search2" v-if="kslb" placeholder="请选择班级">
					<el-option :label="v.mc" :value="v.id+''" v-for="v in bjmclist"></el-option>
				</el-select>
				<el-select v-model="vbjid" clearable class="code-search" @change="search3" v-if="sfbklb" placeholder="请选择班级">
					<el-option :label="v.mc" :value="v.id+''" v-for="v in bjmclist"></el-option>
				</el-select>
			</div>

		</div>
		<div class="gn" style="width: 100%;float: left;margin-top: 5px;">
			<!--<el-button type="primary" plain size="small" @click="kqlist" icon="menu">考勤补课</el-button>
			<el-button type="warning" plain size="small" @click="kslist" icon="menu">弱补</el-button>
			<el-button type="success" plain size="small" @click="sfbklist" icon="menu">收费补课</el-button>-->
			<el-tabs v-model="activeName2" type="border-card" @tab-click="handleClick">
				<el-tab-pane label="考勤补课" name="1">
					<el-table :data="dataList" stripe border size="small" align="center" class="admin-table" @select="checkSelect" @select-all="checkall">
						<div slot='empty'>
							<img src="../../../assets/img/empty.png" style="width:40px;vertical-align: middle;">
							<span style="vertical-align: middle;">暂时还没有内容哦!</span>
						</div>
						<el-table-column :prop="v.prop" :label="v.label" v-for="(v,index) in portTitleList" align="center" show-overflow-tooltip v-if="v.hide != 0" :formatter="v.formatter" :align="v.align || 'center'" :fixed="v.fixed" :class-name="v.columnStyle" :width="v.width" :min-width="v.minWidth" :header-align="v.headerAlign || 'center'">
							<template scope="scope">
								<div slot="reference">
									<div v-if="scope.column.property == 'zwm'" @click="componentsShow('info',scope)">
										<img :src="scope.row.xb == '男' ? $store.state.sexImg.boy : $store.state.sexImg.girl" style="width:20px;vertical-align:middle; float: left;" v-if="scope.column.property == 'zwm'">
										<span style="vertical-align:middle;">{{ scope.row[scope.column.property] }}</span>
									</div>
									<span style="vertical-align:middle;" v-else>{{ scope.row[scope.column.property] }}</span>

								</div>
							</template>
						</el-table-column>
						<el-table-column label="操作" width="200" align="center" v-if="!iscanedit">
							<template scope="scope">
								<el-button size="mini" type="primary" v-if="scope.row.zt=='未安排补课'" @click="componentsShow('bkap',scope)">补课</el-button>
								<el-button size="mini" type="danger" disabled v-if="scope.row.zt=='已安排补课'">{{scope.row.zt}}</el-button>
								<el-button size="mini" type="warning" disabled v-if="scope.row.zt=='已补课'">补课完成</el-button>
							</template>
						</el-table-column>
					</el-table>
					<el-pagination  @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="pageindex" :page-sizes="pagesizes" :page-size="pagesize" :layout="layout" :total="total" class="class-page">
					</el-pagination>
				</el-tab-pane>
				<el-tab-pane label="弱补" name="2">
					<el-table   :data="dataList2" stripe border size="small" align="center" class="admin-table" @select="checkSelect" @select-all="checkall">
						<div slot='empty'>
							<img src="../../../assets/img/empty.png" style="width:40px;vertical-align: middle;">
							<span style="vertical-align: middle;">暂时还没有内容哦!</span>
						</div>
						<el-table-column :prop="v.prop" :label="v.label" v-for="(v,index) in portTitleList2" align="center" show-overflow-tooltip v-if="v.hide != 0" :formatter="v.formatter" :align="v.align || 'center'" :fixed="v.fixed" :class-name="v.columnStyle" :width="v.width" :min-width="v.minWidth" :header-align="v.headerAlign || 'center'">
							<template scope="scope">
								<div slot="reference">
									<div v-if="scope.column.property == 'xsmc'" @click="componentsShow('info',scope)">
										<img :src="scope.row.xb == '男' ? $store.state.sexImg.boy : $store.state.sexImg.girl" style="width:20px;vertical-align:middle; float: left;" v-if="scope.column.property == 'xsmc'">
										<span style="vertical-align:middle;">{{ scope.row[scope.column.property] }}</span>
									</div>
									<span style="vertical-align:middle;" v-else>{{ scope.row[scope.column.property] }}</span>

								</div>
							</template>
						</el-table-column>
						<el-table-column label="操作" width="200" align="center" v-if="!iscanedit">
							<template scope="scope">
								 <el-button size="small" type="primary"   @click="componentsShow('bkap',scope)">补课</el-button> 
								
								<!--<el-button size="mini" type="primary" v-if="scope.row.zt=='未安排补课'" @click="componentsShow('bkap',scope)">补课</el-button>
								<el-button size="mini" type="danger" disabled v-if="scope.row.zt=='已安排补课'">{{scope.row.zt}}</el-button>
								<el-button size="mini" type="warning" disabled v-if="scope.row.zt=='已补课'">补课完成</el-button>-->
							</template>
						</el-table-column>
					</el-table>
				</el-tab-pane>
				<el-tab-pane label="收费补课" name="3">
					<el-table :data="dataList3" stripe border size="small" align="center" class="admin-table" @select="checkSelect" @select-all="checkall">
						<div slot='empty'>
							<img src="../../../assets/img/empty.png" style="width:40px;vertical-align: middle;">
							<span style="vertical-align: middle;">暂时还没有内容哦!</span>
						</div>
						<el-table-column :prop="v.prop" :label="v.label" v-for="(v,index) in portTitleList3" align="center" show-overflow-tooltip v-if="v.hide != 0" :formatter="v.formatter" :align="v.align || 'center'" :fixed="v.fixed" :class-name="v.columnStyle" :width="v.width" :min-width="v.minWidth" :header-align="v.headerAlign || 'center'">
							<template scope="scope">
								<div slot="reference">
									<div v-if="scope.column.property == 'xsmc'" @click="componentsShow('info',scope)">
										<img :src="scope.row.xb == '男' ? $store.state.sexImg.boy : $store.state.sexImg.girl" style="width:20px;vertical-align:middle; float: left;" v-if="scope.column.property == 'xsmc'">
										<span style="vertical-align:middle;">{{ scope.row[scope.column.property] }}</span>
									</div>
									<span style="vertical-align:middle;" v-else>{{ scope.row[scope.column.property] }}</span>

								</div>
							</template>
						</el-table-column>
						<el-table-column label="操作" width="200" align="center" v-if="!iscanedit">
							<template scope="scope">
								<el-button size="mini" type="primary" @click="componentsShow('bkap',scope)">补课</el-button>
								<!--<el-button size="mini" type="danger" disabled v-if="scope.row.zt=='已安排补课'">{{scope.row.zt}}</el-button>-->
								<!--<el-button size="mini" type="warning" disabled v-if="scope.row.zt=='已补课'">补课完成</el-button>-->
							</template>
						</el-table-column>
					</el-table>
				</el-tab-pane>
			</el-tabs>
		</div>
		<!-- 各个组件显示区域 -->
		<!-- 动画加载 -->
		<LoadingComponent v-show="isLoading"></LoadingComponent>
		<BkapComponent v-if="portComponents.bkap.toggle" @close="componentsHide" :params="portComponents.bkap.params"></BkapComponent>
		<infoComponent v-if="portComponents.info.toggle" @close="componentsHide" :params="portComponents.info.params"></infoComponent>
		<router-view class="port-view"></router-view>
	</div>
</template>
<script>
	import { mapState } from 'vuex'
	import LoadingComponent from 'components/loading'
	import BkapComponent from 'components/xzhomezj/buke/bkap'
	import InfoComponent from 'view/educa/classManage/student/info'
	import qs from 'qs'
	export default {
		components: {
			BkapComponent,
			LoadingComponent,
			InfoComponent
		},
		data() {
			return {
				activeName2: '1',
				bjmc: '',
				kqlb: true,
				kslb: false,
				sfbklb: false,
				vbjid: '', // 班级id
				checked1: '',
				checked2: '',
				visqy: 'N',
				iscanedit: false, //显示编辑的数字框

				multipleDelNum: '', //获取批量选择的数据
				dataList: [], //表格数据
				dataList2: [], //表格数据
				dataList3: [], //表格数据
				comboxlist: [], //下拉框 动态的
				kslxlist: [],
				bjmclist: [],
				vcomautovalue: '', //下拉框name 动态的
				vcomgdvalue: '', //下拉框name 固定的

				/*动画加载*/
				isLoading: true, //动画加载
				searchLoading: false, //搜索按钮触发按钮动画
				/*分页属性设置*/
				layout: 'total, sizes, prev, pager, next, jumper', //组件布局
				pageindex: this.$store.state.pageindex, //当前分页页码
				pagesizes: this.$store.state.pagesizes, //显示个数的选择器选项
				pagesize: this.$store.state.pagesize, //每页显示条目数
				total: 0, //总条数

				/*组件区域*/
				portComponents: {
					/* 单行删除  */
					singleDelete: {
						type: 'singleDelete',
						toggle: false,
						params: '',
						data: {
							index: '',
							type: 'single',
							title: '此操作将删除该记录?, 是否继续?'
						}
					},
					/* 批量删除 */
					multipleDelete: {
						type: 'multipleDelete',
						toggle: false,
						params: '',
						data: {
							index: '',
							type: 'multiple',
							title: '此操作将删除您选中的记录?, 是否继续?'
						}
					},

					bkap: {
						type: 'bkap',
						toggle: false,
						params: '',
						data: {}
					},
					info: {
						type: 'info',
						toggle: false,
						params: '',
						data: {}
					}
				},
				/*
				    prop :  接口参数名
				    label : 接口中文名
				    hide : 是否隐藏这一列
				    align : 这一列对齐顺序 ： left,right,center
				    headerAlign : 这一列表头对齐方式 ： left,right,center
				*/
				portTitleList: [

					{
						prop: 'id',
						label: 'id',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
					{
						prop: 'zwm',
						label: '学生',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
					{
						prop: 'bjmc',
						label: '班级',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},

					{
						prop: 'day',
						label: 'Day',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},

				],
				portTitleList2: [

					{
						prop: 'id',
						label: 'id',
						hide: 0,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
					{
						prop: 'zwm',
						label: '学生',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
					{
						prop: 'bjmc',
						label: '班级',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
					{
						prop: 'bkcs',
						label: '弱补次数',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
					{
						prop: 'kslx',
						label: '考试类型',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
					{
						prop: 'score',
						label: '考试分数',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
					{
						prop: 'bk',
						label: '最近补课老师',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},

				],

				portTitleList3: [

					{
						prop: 'zwm',
						label: '学生',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
					{
						prop: 'bjmc',
						label: '班级',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
					{
						prop: 'bk',
						label: '最近补课老师',
						hide: 1,
						align: 'center',
						fixed: false,
						width: '',
						minWidth: '',
						headerAlign: 'center',
						formatter: function(row, column) {}
					},
				]
			}
		},
		created() {
			//加载页面时调用
			if(this.$route.query.iid) {
				this.vbjid = this.$route.query.iid + ''
			}
			if(this.$route.query.bjmc) {
				this.bjmc = this.$route.query.bjmc
			}
			this.$store.dispatch('changeTitle', this.bjmc + '待补课学生'); //修改title
			this.$store.dispatch('changeRouterIndex', '/educa/bklist'); //修改路由

			this.search(); //分页获取默认数据
			this.getbjmc()

			this.isLoading = true; //动画开始
			if(this.$route.query.iid) {
				if(this.$route.query.frompage == 'xsbk') {
					this.componentsShow("edit");
				}
			}
		},
		mounted() {
			//加载完成之后event
			this.isLoading = false; //动画结束
		},
		methods: {
			handleClick(tab, event) {
				if(tab.name == '1') {
					this.kqlist()
				} else if(tab.name == '2') {
					this.kslist()
				} else if(tab.name == '3') {
					this.sfbklist()
				}
			},
			kqlist() {
				this.search()
				this.kqlb = true;
				this.kslb = false;
				this.sfbklb = false;
			},
			kslist() {
				this.search2();
				this.kqlb = false;
				this.kslb = true;
				this.sfbklb = false;
			},
			sfbklist() {
				this.search3();
				this.kqlb = false;
				this.kslb = false;
				this.sfbklb = true;
			},
			search() {
				//查询搜索触发事件
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					bjid: this.vbjid,
					xxid: logininfo.xxid,
					pageindex: this.pageindex,
					pagesize: this.pagesize,

				})
				//执行
				this.axios.post(this.$store.state.api + 'kqjl/kscjlist', params2)
					.then(res => {
						console.log(res, 'sssssssssssssssssss')
						let data = res.data.data;
						let list = data.list;
						// let result = data.list[0].result;
						this.total = data.totalPage;
						this.dataList = list;
						this.searchLoading = false;
					}).catch(res => {
						this.searchLoading = false;
					})
			},
			search2() {
				//查询搜索触发事件
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					bjid: this.vbjid,
					zt: 'Y',
					xxid: logininfo.xxid,
					yhid: logininfo.id + '',
				})
				//执行
				this.axios.post(this.$store.state.api + 'xs/list1', params2)
					.then(res => {
						let data = res.data.data;
						let list = data.list;
						this.total = data.totalPage;
						this.dataList2 = list;
						console.log(this.dataList2 ,22666)
						this.searchLoading = false;
					}).catch(res => {
						this.searchLoading = false;
					})
			},
			search3() {
				//查询搜索触发事件
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					bjid: this.vbjid,
					zt: 'Y',
					yhid: logininfo.id + '',
					xxid: logininfo.xxid + ''
				})
				//执行
				this.axios.post(this.$store.state.api + 'xs/list', params2)
					.then(res => {
						console.log(res, 989888888)
						let data = res.data.data;
						let list = data.list;
						this.total = data.totalPage;
						this.dataList3 = list;
						this.searchLoading = false;
					}).catch(res => {
						this.searchLoading = false;
					})
			},
			getbjmc() {
				//查询搜索触发事件
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					xxid: logininfo.xxid,
					yhid: logininfo.id
				})
				//执行
				this.axios.post(this.$store.state.api + 'bj/getbj', params2)
					.then(res => {
						let data = res.data.data;
						let list = data.list;
						// let result = data.list[0].result;
						this.bjmclist = list;
						this.searchLoading = false;
					}).catch(res => {
						this.searchLoading = false;
					})
			},

			tableCellControl(scope) {
				//表格单元格控制CSS样式
				/*if (scope.row.id == 112 && scope.column.property == "iname") {
				    return {
				        color:"red",
				    }
				}else{
				    return {
				        color:"green",
				    }
				}*/
			},
			
			handleSizeChange(val) { //每页显示条数触发事件
				this.pagesize = val;
				this.pageindex = 1;
				this.search();
			},
			handleCurrentChange(val) { //分页触发事件
					this.search();
			},
			checkSelect(selection, row) { //点击单选select触发事件
				let strID = [];
				selection.forEach(function(v, i) {
					strID.push(v.id)
				})
				this.multipleDelNum = strID.join(",");
			},
			checkall(selection) { //点击全选select触发事件
				let strID = [];
				selection.forEach(function(v, i) {
					strID.push(v.id)
				})
				this.multipleDelNum = strID.join(",");
			},
			/* 组件的弹框  */
			componentsShow(type, data) { //显示组件
				for(let i in this.portComponents) {
					if(type == this.portComponents[i].type) {
						this.portComponents[i].toggle = true;
						this.portComponents[i].params = data;
						if(this.portComponents[i].data.type == 'single') {
							this.portComponents[i].data.index = data.row.id
						} else if(this.portComponents[i].data.type == 'multiple') {
							this.portComponents[i].data.index = this.multipleDelNum;
						} else {
							return;
						}
						return;
					}
				}
			},
			componentsHide(setting) { //关闭组件
				this.search();
				this.search2();
				for(let i in this.portComponents) {
					if(setting.type == this.portComponents[i].type) {
						this.portComponents[i].toggle = false;
						if(!setting.cancel) {
							this.search();
						}
						return;
					}
				}
			}
		},
		computed: {
			...mapState([
				'api' //域名
			]),
			multipleDeleteDisabled() {
				if(this.multipleDelNum) {
					return false;
				} else {
					return true
				}
			}
		}
	}
</script>

<style lang="less" scoped>
	.port-page {
		font-size: 12px;
		.btn {
			height: 30px;
			padding: 0 10px
		}
		.code-search {
			height: 30px;
			/*margin:10px 0 10px 0;*/
			min-width: 120px;
			max-width: 150px;
		}
		.el-button+.el-button {
			margin-left: 0px;
		}
		.class-page {
			text-align: left;
			margin-top: 20px;
		}
		.search-item {
			display: inline-block;
			margin-right: 10px;
		}
		.ys2 {
			color: #F7BA2A;
		}
		.but1 {
			width: 100%;
			height: 50px;
			line-height: 50px;
			float: left;
			.but2 {
				float: right;
			}
		}
		.search {
			width: 70%;
			float: right;
			text-align: right;
		}
	}
	
	.tab[data-v-40466893] {
		top: 10px;
	}
</style>